﻿using ConfExpert.Forms.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevTeam;
using System;
using System.Windows.Forms;

namespace ConfExpert.Forms.Planlama
{
    public partial class BM : XForm
    {
        public BM()
        {
            InitializeComponent();
        }

        BindingSource bs;
        private void BM_Load(object sender, EventArgs e)
        {
            
            TAM.BMetrajTableAdapter = new Datasets.MyDataTableAdapters.BMetrajTableAdapter();

            bs = new BindingSource(ds, "BMetraj");
            InitGridView(gvBM, bs);
            GetDetails("BMetraj", "GetBMetraj");

            gvBM.FormatAsNumber(1, "KumasEni", "RaporBoyu", "Garni1", "Garni2", "Garni3", "Garni4", "Garni5", "Guid", "Profilo", "BedenBM", "BedenBMBuyuk", "ToplamBM");

            /*
             * DİKKAT: TAM'a uygun değil bu yapı!
            bs = gvBM.Init("GetBMetraj");
            gvBM.SetIdentity("BMetrajId");
            */
            gvBM.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom;
            gvBM.Columns["Tarih"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            gvBM.Columns["Tarih"].DisplayFormat.FormatString = "d"; //G
            gvBM.AddSummary();
            gvBM.BestFitColumns();

            AddBsToList(bs);
            btnKaydet.Visibility = ytk(107) ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never;
            btnKaydet.ItemClick += btnKaydet_ItemClick;
            btnGuncelle.ItemClick += btnGuncelle_ItemClick;
        }

        void btnGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GetDetails("BMetraj", "GetBMetraj");
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Save();
        }
    }
}